Ext.onReady(function() {
	 Ext.apply(Ext.form.VTypes, {
        confirmPassword : function(val, field) {
            if (field.initialPassField) {
                var pwd = Ext.getCmp(field.initialPassField);
                return (val == pwd.getValue());
            }
            return true;
        },
        confirmPasswordText : '两次输入的密码不一致!'
    });
	var pwdPanel = Ext.create('Ext.form.Panel', {
		renderTo : 'pwd-panel',
		title : '修改密码',
		//height : 500,
		bodyPadding : 20,
		//frame:true,
        autoScroll:true,
        fieldDefaults: {
            labelAlign: 'right',
            labelWidth: 90,
            width: 300,
            msgTarget: 'side'
        },
		items : [{
			xtype: 'textfield',
			name : 'old_password',
			fieldLabel : '原密码',
			emptyText : '原密码',
			style : 'margin-left:auto;margin-right:auto;',
			inputType:"password",
			allowBlank : false
		}, {
			xtype: 'textfield',
			id:'new_password',
			name : 'new_password',
			fieldLabel : '新密码',
			emptyText : '新密码',
			style : 'margin-left:auto;margin-right:auto;',
			inputType:"password",
			allowBlank : false
		},{
			xtype: 'textfield',
			name : 'confirm_password',
			fieldLabel : '确认密码',
			emptyText : '确认密码',
			style : 'margin-left:auto;margin-right:auto;',
			vtype:"confirmPassword",
			initialPassField : 'new_password',
			inputType:"password",
			allowBlank : false
		},{
			xtype : 'container',
			style : 'text-align:center',
			items : [{
				xtype : 'button',
				text : '修改',
				handler:function(){
        			if (pwdPanel.getForm().isValid()) {
        				pwdPanel.getForm().submit({
        					waitTitle : '请稍候',
        					waitMsg : '正在处理......',
        					url : '/usercontrol/sysuser_change_pwd/',
        					success : function(form, action) {
        						Ext.Msg.alert('系统提示', action.result.message);
        					},
							failure : function(form, action) {
								if (action.result) {
									Ext.Msg.alert('系统提示', action.result.message);
								} 
							}
        				});
        			}					
				}
			}]
		}]
		
	});
});